package com.yc.http.d0626;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;

public class HttpServletRequest {

    private InputStream inputStream;

    private String requestURI;

    public HttpServletRequest(InputStream inputStream) throws IOException {
        this.inputStream = inputStream;
        try{
            // 读取请求报文
            byte[] buffer = new byte[1024 * 10];
            int count = inputStream.read(buffer);
            String requestStr = new String(buffer, 0, count);
            System.out.println(requestStr);
            // 获取资源地址
            String[] lines = requestStr.split("\n");
            String[] items = lines[0].split("\\s");
            requestURI = items[1];

        } catch (IOException e) {
            throw e;
        }
    }

    public String getRequestURI() {
        return requestURI;
    }
}
